package com.yym.duotai;

/*

父类引用只能调用父类所声明的方法和属性，不可调用子类独有的属性和方法
 */
public class testBasic {
    public static void main(String[] args) {
        //将狗对象当成动物来看
        Animal animal = new Dog();
        animal.eat();

        // 将狗对象当成狗来看
        Dog dog = new Dog();
        dog.eat();
        dog.run();
        System.out.println(dog.sex);

    }
}
    class Animal {
        String name;
        int age;
        String sex;

        public void eat() {
        }

        public void sleep() {
        }
    }

  class Dog extends Animal {
        String furColor;

        public void run() {
        }
    }
